import javax.servlet.ServletContext;
import javax.servlet.annotation.WebServlet;
import javax.servlet.http.HttpServlet;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import java.io.IOException;
import java.io.PrintWriter;

@WebServlet("/contextservlet01")
public class ContextServlet01 extends HttpServlet {
    @Override
    protected void service(HttpServletRequest rep,
                           HttpServletResponse resp) throws  IOException {
        resp.setContentType("text/html;charset=Utf-8");
        PrintWriter pw = resp.getWriter();
        ServletContext context =this.getServletContext();
        String param = context.getInitParameter("databaseURL");
        pw.println("数据库连接URL:" +param);
    }

}